package org.itstack.chain;

/**
 * 责任链模式演示类
 * 展示不同金额的审批申请如何通过责任链处理
 */
public class ChainOfResponsibilityDemo {
    
    public static void main(String[] args) {
        // 创建审批系统
        ApprovalSystem approvalSystem = new ApprovalSystem();
        
        // 显示审批链信息
        approvalSystem.printChainInfo();
        
        // 测试不同金额的审批申请
        testApprovalRequests(approvalSystem);
    }
    
    /**
     * 测试不同金额的审批申请
     */
    private static void testApprovalRequests(ApprovalSystem approvalSystem) {
        System.out.println("=== 开始测试审批申请 ===\n");
        
        // 测试案例1：500元申请 - 应该由部门经理审批
        ApprovalRequest request1 = new ApprovalRequest(
            "REQ001", "张三", "技术部", 500.0, 
            "购买办公用品", "购买打印机墨盒"
        );
        approvalSystem.submitRequest(request1);
        
        // 测试案例2：3000元申请 - 应该由总经理审批
        ApprovalRequest request2 = new ApprovalRequest(
            "REQ002", "李四", "市场部", 3000.0, 
            "市场推广", "购买广告位"
        );
        approvalSystem.submitRequest(request2);
        
        // 测试案例3：8000元申请 - 应该由董事长审批
        ApprovalRequest request3 = new ApprovalRequest(
            "REQ003", "王五", "财务部", 8000.0, 
            "设备采购", "购买服务器设备"
        );
        approvalSystem.submitRequest(request3);
        
        // 测试案例4：15000元申请 - 应该由董事会审批
        ApprovalRequest request4 = new ApprovalRequest(
            "REQ004", "赵六", "研发部", 15000.0, 
            "项目投资", "购买开发工具和软件"
        );
        approvalSystem.submitRequest(request4);
        
        // 测试案例5：50元申请 - 应该由部门经理审批
        ApprovalRequest request5 = new ApprovalRequest(
            "REQ005", "钱七", "人事部", 50.0, 
            "日常办公", "购买文具用品"
        );
        approvalSystem.submitRequest(request5);
        
        System.out.println("=== 测试完成 ===");
    }
}
